@extends('admin.layouts.app')
@section('content')

                        <div class="row">
                            <div class="col-sm-12">
                                <h4 class="page-title">工单管理</h4>
                                <ol class="breadcrumb">
                                    <li><a href="#">系统</a></li>
                                    <li><a href="{{url('zadmin/task')}}">任务管理</a></li>
                                    <li class="active">任务详情</li>
                                </ol>
                            </div>
                        </div>
                        
                        <div class="row">
                        	<div class="col-lg-12">
                        		<div class="card-box">
                            <h2 class="m-t-0 header-title">工单详情</h2>
                            <hr/>
                             
      <div class="row">
			   <div class="col-md-6">
                                 
<table class="table table-hover">
                <tr>
                  <td>标题</td>
                  <td><strong>{{$data->title}}</strong></td>
                </tr>
                <tr>
                  <td>业主名称</td>
                  <td>{{$data->customer_name}}</td>
                </tr>
                <tr>
                  <td>小区</td>
                  <td>{{$data->village_name}}</td>
                </tr>
                <tr>
                  <td>区域</td>
                  <td>{{$data->category->name or ''}}</td>
                </tr>
                <tr>
                  <td>其他问题</td>
                  <td>{{$data->remark}}</td>
                </tr>
                <tr>
                  <td>状态</td>
                  <td><label class="label label-{{$taskStatus[$data->status]['style']}}">{{$taskStatus[$data->status]['txt']}}</label></td>
                </tr>
              </table>
              <hr/>
              @if($replies)
              <div class="row">
              <h4>处理记录</h4>       
                     <div class="col-md-12">
                     <table class="table">
                       @foreach($replies as $reply)
                       <tr>
                        <td>
                       {{$reply->fromUser->truename or ''}} ：
                       <p> {{$reply->msg}} &nbsp;&nbsp;  {{$reply->created_at}}
                       </p>
                      </td>
                       </td></tr>
                       @endforeach
                        </table>
                     </div>
                     {{ $replies->links() }}
              </div>
              @endif
              <hr/>
              @if( $data->status!=App\Http\Controllers\Controller::COMPLETED_STATUS)
              <div class="row">    
              <div class="alert alert-{{ array_get(session('rs'),'status') }}" style="display: {{session('rs')?'block':'none'}}">
                                {{ array_get(session('rs'),'msg') }}
              </div>
              <form class="form-horizontal" role="form" action="{{url('zadmin/task/reply')}}" method="post" id="form1">
                <div class="form-group">
                  <label class="col-md-2 control-label">回复</label>
                  <div class="col-md-6">
                    <textarea class="form-control" rows="5" name="msg"></textarea>
                  </div>
                </div>
                <div class="form-group text-center"> 
                <div class="col-md-10"> 
                <button data-status="{{$data->status}}" type="button" class="btn btn-default waves-effect waves-light task-btn">回复</button> 
                @if($data->user_id != session('admin')->id) 
                @if( $data->status == App\Http\Controllers\Controller::WAIT_STATUS)
                  <button data-status="50" type="button" class="btn btn-info waves-effect waves-light task-btn">开始</button>
                @endif                                 
                <button data-status="100" type="button" class="btn btn-primary waves-effect waves-light task-btn" >完成</button>
                @endif
                </div>
                </div>
                <input type="hidden" name="to_user_id" value="{{$data->user_id}}"/>
                <input type="hidden" name="task_id" value="{{$data->id}}" />
                <input type="hidden" name="status" value=""/>
                {{csrf_field()}}
              </form>  
              </div>
              @endif
                                              
                                              
                            
                                          
        </div>			                        	
			</div>
    </div>
                                
                            </div> <!-- end col -->

                            
                        </div>
@endsection
                        
  @section('js')
<script type="text/javascript">
  $('.task-btn').on('click',function(){
    var status = $(this).data('status');
    $('input[name="status"]').val(status);
    $('#form1').submit();
  });
</script>


@endsection                      
                        

                  
            
        
       

           



    
        
    
